package com.fanfutian.eventproject.mapper;


import com.fanfutian.eventproject.pojo.Category;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface CategoryMapper {


    /**
     * 添加分类
     * @param category
     */
    @Insert("insert into db_event_project.category(category_name, category_alias, create_user, create_time, update_time) " +
    "values (#{categoryName}, #{categoryAlias}, #{createUser}, now(), now())")
    void addCategory(Category category);


    /**
     * 获取分类列表
     * @param userId
     */
    @Select("select * from db_event_project.category where create_user = #{userId}")
    List<Category> getCategoryList(Integer userId);


    /**
     * 获取分类详情
     * @param id
     * @return
     */
    @Select("select * from db_event_project.category where id = #{id}")
    Category detail(Integer id);


    /**
     * 更新分类信息
     * @param category
     */
    @Update("update db_event_project.category set category_name = #{categoryName}, category_alias = #{categoryAlias}, update_time = now() where id = #{id}")
    void updateCategoryInfo(Category category);


    /**
     * 删除分类信息
     * @param id
     */
    @Delete("delete  from  db_event_project.category where id = #{id}")
    void deleteCategoryInfo(Integer id);
}
